package com.sanploy.fed.push.dao;


import com.sanploy.fed.push.bean.GovNews;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2016/8/1.
 */
@Repository
public interface GovNewsDao  extends CrudRepository<GovNews,Long> {
    @Query(value = "SELECT * FROM govnews where classid = ? ORDER BY addtime DESC LIMIT ?,?",nativeQuery = true)
    public List<GovNews> findByClassLimit(Long newsClass, int start, int end);

    @Query(value = "SELECT * FROM govnews where classid = ?",nativeQuery = true)
    public List<GovNews> findNewsByClassid(Long newsClass);

    @Query(value = "SELECT * FROM govnews  WHERE classid != 6 ORDER BY addtime DESC LIMIT ?,?",nativeQuery = true)
    public List<GovNews> findByPage(int start, int end);

    @Query(value = "SELECT * FROM govnews ORDER BY addtime DESC LIMIT ?,?",nativeQuery = true)
    public List<GovNews> findByPageAll(int start, int end);

    @Query(value = "SELECT count(*) FROM govnews  where classid = ?",nativeQuery = true)
    public Long findByPageAll(Long id);

    @Query(value = "SELECT * FROM govnews  where title LIKE ?",nativeQuery = true)
    public List<GovNews> searchTitle(String keys);


}
